import 'package:hive/hive.dart';

import '../models/user.dart';
import '../models/user_company.dart';

class UserAdapter extends TypeAdapter<User> {
  @override
  final int typeId = 1;

  @override
  User read(BinaryReader reader) {
    return User(
      id: reader.read() as String?,
      gmtCreate: reader.read() as String?,
      gmtModified: reader.read() as String?,
      phone: reader.read() as String?,
      reference: reader.read() as String?,
      referenceCompany: reader.read() as String?,
      registerTime: reader.read() as String?,
      companyId: reader.read() as String?,
      appCompanyDto: reader.read() as AppCompanyDto?,
    );
  }

  @override
  void write(BinaryWriter writer, User obj) {
    writer.write(obj.id);
    writer.write(obj.gmtCreate);
    writer.write(obj.gmtModified);
    writer.write(obj.phone);
    writer.write(obj.reference);
    writer.write(obj.referenceCompany);
    writer.write(obj.registerTime);
    writer.write(obj.companyId);
    writer.write(obj.appCompanyDto);
  }
}
